home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Business Heaven
/
Business Heaven.iso
/
members
/
rand
/
rand2.hlp
< prev
next >
Wrap
Text File
|
1993-09-05
|
5KB
|
125 lines
PROGRAM:Raffle Gen VER:5.5
DESCR:Pulls 4 digit #s out of Hat (not same # twice)
AUTHOR:FAST ENTRY PROGRAMMING
Walter Killeen
210 S. Lopez St.
New Orleans, LA 70119
(504)827-5989
Compuserve:71511,35
FidoNet:1:396/17.22
Requires:DOS3.1 Monitor:CGA or Mono
Drive:Hard or ram (for performance)
Registration $25
Rand2.exe is a random number Generator of excellent flexibility.
It was designed to produce a WINNING number such as is used in a
raffle or door prize situation. Once it picks a winner, and
displays it with suitable fanfare on the screen, that number,
along with the time and date it was picked will be added to a
list of numbers no longer considered valid for choosing. (Sort of
like pulling tickets from a hat)
In addition if the file GoodNums.lst exists, only numbers that
exist in that file are considered valid. Further, the order in
which a number is entered in the file HAS NO BEARING on how
likely it will be picked.
┌───────────────────┐
│HOW RAND2.EXE WORKS│
└───────────────────┘
To start Rand type: RAND2 {Which Random to Pick}
1. If the File: GoodNums.lst exists and contains, on its first
line the words:ALL VALID NUMBERS, RAND2 will count the number
of lines that it contains and save it (in NumOfLines for those
of you tracking the source code)
2. Based on the microsecond that the random number generator is
started an x digit random number is generated (one digit at a
time). X is based on the number of digits in the NumOfLines
variable above. The number is then checked to be sure that it
is less than or equal to NumOfLines. If so, it is copied to
LineWin (integer) and ThisNumStr (a text string) otherwise
another x digit random number is generated.
3. If the File: GoodNums.lst exists, the file will be scanned
sequentially for the line number stored in the random number
already generated in step 2.
a. The first four digits are read into ThisNumStr for
later checking in the USEDNUMS file.
b. any remaining text on the same line (up to 40
characters) will be read into the variable: MemberName
for display and recording later.
If the file: GOODNUMS.LST doesn't exist the random number will
be considered valid at this point.
4. RAND2 then opens the file:USEDNUMS.lst to see if the number
was already used. If it has, you guessed it back to step 2.
Until the file of used numbers is erased, previous winners
cannot win again.
5. At this point, RAND has generated a number which IS both a
member of the first list and NOT a member of the second. It
now calls the TITLE.exe to display the number and whether or
not it won! Remember that little parameter that you started
the program with? Lets say that you started with 3.
RAND2 would display the first two numbers as non-winners and
the third would be marked the winner. ONLY the number marked
as a winner goes into USEDNUMS.LST. Since we actually started
the random number generator with a random number. NO WAY to
fix the output. If the GOODNUMS.LST file is used, it's full
path is displayed at the time the numbers are displayed and
the name is hard coded into the program. If used GoodNums.Lst
MUST exist in the same path that RAND.EXE is in.
┌───────────────────┐
│GOODNUMS.LST FORMAT│
└───────────────────┘
As mentioned above, GOODNUMS.LST is a simple ascii text file. The
first line MUST read: ALL VALID NUMBERS (all caps, no leading or
trailing spaces) after that, each valid number can be entered in
any order on a line by itself. Use a standard text editor (such
as Edlin) to create the file. Although only the first four
characters are used for comparison,the rest of the line can
contain any text that you wish. (member first and last name
suggested)
┌───────────┐
│PERFORMANCE│
└───────────┘
Yes, I know that I could have read all the numbers into an array
and sorted the list first but this is one of the few times when
the object is to create suspense. Let the computer churn a while.
I didn't want the program to get the answer too quickly.. Some
things are best done SLOWLY.. If you really want slow, run from a
floppy disk.
┌────────┐
│FAIRNESS│
└────────┘
For those of you astute enough to spot it, RAND2 does have a
major flaw. If some unscrupulous individual entered his number
more than once (ok a lot more than once) he would have an unfair
advantage over the others. Although the list doesn't need to be
sorted, sorting it just before the drawing and checking for
duplicates could minimize that possibility.
If you want to eliminate that possibility use my RAND program
(Ver 5.5) and sleep well, knowing that no one can accuse you of
cheating... It is a little bit slower than RAND2 but uses a
different technique of validating which negates number frequency
problems. While RAND2 seems almost instantaneous (it only scans
the GoodNums file once for each winner.) RAND has been known to
take up to SEVEN to THIRTY SECONDS to find a random number it is
happy with.
If you need a quick reference (file names and such) just type
Rand2 ?
In addition, see Vendor.doc for the use of each file.